package org.example.login.controller;

import org.example.login.service.UitlsService;
import org.example.login.service.WxSessionService;

import org.example.feign.pojo.JsCode2SessionResponse;
import org.example.feign.pojo.JsCodeRequest;
import org.example.login.Proxy.JsCode2SessionServiceProxy;
import org.example.login.service.JsCode2SessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class JsCode2SessionController {

    @Autowired

    private final UitlsService UitlsService;
    private final WxSessionService WxSessionService;


    public JsCode2SessionController( UitlsService uitlsService, WxSessionService wxSessionService) {
        this.UitlsService = uitlsService;
        this.WxSessionService = wxSessionService;
    }

    @PostMapping("/jscode2session")
    public JsCode2SessionResponse getJsCode2Session(@RequestBody JsCodeRequest request) throws IOException {
        JsCode2SessionService service = new JsCode2SessionServiceProxy(UitlsService,WxSessionService);
        return service.getJsCode2Session(request);
    }
}
